package com.xianyun.site.support.executor.handle.smtp.v20201108.impl;

import com.aliyuncs.dm.model.v20151123.BatchSendMailRequest;
import com.aliyuncs.dm.model.v20151123.SingleSendMailRequest;
import com.xianyun.site.support.domain.model.SmtpMessage;
import com.xianyun.site.support.executor.handle.smtp.BaseSmtpStrategy;
import org.springframework.stereotype.Component;

/**
 * 邮件校验策略
 * @author mac_zyj
 */
@Component
public class ISmtpCheckStrategyImpl extends BaseSmtpStrategy {

    @Override
    public SingleSendMailRequest sendSingleMailRequest(SmtpMessage message) {
        SingleSendMailRequest request = initSingleSendMail(message);
        String fileKey = message.getFileKey();
        String httpBody =getHtmlBodyByUrl(fileKey,message.getFileLocation())
                .replace("[toAddress]", message.getToAddress()).replace("[code]",message.getCheckCode());
        request.setHtmlBody(httpBody);
        return request;
    }

    @Override
    public BatchSendMailRequest sendBatchMailRequest() {
        return null;
    }
}
